```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MyBatis ResultMap与ResultType解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-self;
            color: #333;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #4a6cf7 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .code-block {
            font-family: 'Courier New', Courier, monospace;
            background-color: #f8f9fa;
            border-radius: 6px;
            padding: 1rem;
            overflow-x: auto;
        }
        .highlight {
            position: relative;
        }
        .highlight:before {
            content: "";
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 4px;
            background: #4a6cf7;
            border-radius: 2px;
        }
        .mermaid {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .footer-link:hover {
            color: #a5b4fc !important;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-4xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">MyBatis映射机制解析</h1>
            <p class="text-xl md:text-2xl mb-8 font-serif">深入理解ResultMap与ResultType的区别与应用场景</p>
            <div class="flex justify-center space-x-4">
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full flex items-center">
                    <i class="fas fa-database mr-2"></i> ORM框架
                </span>
                <span class="px-4 py-2 bg-white bg-opacity-20 rounded-full flex items-center">
                    <i class="fas fa-code mr-2"></i> MyBatis
                </span>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <p class="text-lg text-gray-700 leading-relaxed mb-6">
                在MyBatis框架中，<code class="bg-gray-100 px-2 py-1 rounded">ResultMap</code>和<code class="bg-gray-100 px-2 py-1 rounded">ResultType</code>都是用来映射查询结果的重要机制，但它们在功能和使用场景上有着显著的区别。本文将深入分析两者的特性、适用场景以及如何在实际开发中选择合适的映射方式。
            </p>
        </section>

        <!-- Comparison Section -->
        <section class="mb-16 grid md:grid-cols-2 gap-8">
            <!-- ResultMap Card -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                <div class="p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-100 p-3 rounded-full mr-4">
                            <i class="fas fa-map text-blue-600 text-xl"></i>
                        </div>
                        <h2 class="text-2xl font-bold text-gray-800">ResultMap</h2>
                    </div>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>灵活的映射方式，可通过XML或注解定义</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>支持列名与属性名的自定义映射</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>支持复杂查询：多表联合、嵌套查询等</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>可重用，提高代码可维护性</span>
                        </li>
                    </ul>
                </div>
                <div class="px-6 py-4 bg-gray-50 border-t border-gray-200">
                    <span class="inline-block bg-blue-100 text-blue-800 text-sm font-medium px-3 py-1 rounded-full">推荐场景</span>
                    <p class="text-sm text-gray-600 mt-2">复杂查询、多表关联、需要自定义映射规则的情况</p>
                </div>
            </div>

            <!-- ResultType Card -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                <div class="p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-100 p-3 rounded-full mr-4">
                            <i class="fas fa-bolt text-purple-600 text-xl"></i>
                        </div>
                        <h2 class="text-2xl font-bold text-gray-800">ResultType</h2>
                    </div>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>简单的映射方式，直接指定Java对象类型</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>列与属性按顺序自动映射</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>配置简单，使用便捷</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                            <span>缺乏灵活性，不能重用</span>
                        </li>
                    </ul>
                </div>
                <div class="px-6 py-4 bg-gray-50 border-t border-gray-200">
                    <span class="inline-block bg-purple-100 text-purple-800 text-sm font-medium px-3 py-1 rounded-full">推荐场景</span>
                    <p class="text-sm text-gray-600 mt-2">简单查询、单表操作、字段名与属性名一致的情况</p>
                </div>
            </div>
        </section>

        <!-- Key Differences Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-6 flex items-center">
                <i class="fas fa-balance-scale text-blue-500 mr-3"></i>
                核心区别对比
            </h2>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">对比项</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ResultMap</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ResultType</th>
                                </tr>
                            </thead>
                            <tbody class="bg-white divide-y divide-gray-200">
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">映射方式</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">自定义映射规则</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">自动按顺序映射</td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">复杂度</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">支持复杂查询</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">仅支持简单查询</td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">可重用性</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">可重复使用</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">每次需重新定义</td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">性能</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">稍低（需解析映射）</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">较高</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-6 flex items-center">
                <i class="fas fa-project-diagram text-blue-500 mr-3"></i>
                使用场景决策树
            </h2>
            <div class="mermaid">
                graph TD
                    A[开始] --> B{查询复杂度}
                    B -->|简单查询| C[使用ResultType]
                    B -->|复杂查询| D[使用ResultMap]
                    D --> E{是否多表关联}
                    E -->|是| F[定义关联映射]
                    E -->|否| G[定义基本映射]
            </div>
        </section>

        <!-- Code Example Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-6 flex items-center">
                <i class="fas fa-code text-blue-500 mr-3"></i>
                代码示例
            </h2>
            
            <div class="grid md:grid-cols-2 gap-6">
                <!-- ResultMap Example -->
                <div class="highlight">
                    <div class="px-4 py-3 bg-gray-800 text-white rounded-t-lg flex justify-between items-center">
                        <span class="font-mono text-sm">ResultMap示例</span>
                        <button class="text-xs bg-gray-700 hover:bg-gray-600 px-2 py-1 rounded" onclick="copyCode('resultmap-code')">
                            <i class="far fa-copy mr-1"></i>复制
                        </button>
                    </div>
                    <pre id="resultmap-code" class="code-block rounded-b-lg"><code>&lt;resultMap id="userResutlMap" type="com.ts.entity.User"&gt;
    &lt;!-- 基础字段映射 --&gt;
    &lt;id column="id" property="id"/&gt;
    &lt;result column="username" property="username"/&gt;
    &lt;result column="password" property="pw"/&gt;
    
    &lt;!-- 对多关联 --&gt;
    &lt;collection property="deptlist" javaType="com.qf.entity.Dept"&gt;
        &lt;id column="dept_id" property="id"/&gt;
        &lt;result column="dept_name" property="name"/&gt;
    &lt;/collection&gt;
    
    &lt;!-- 对一关联 --&gt;
    &lt;association property="emp" javaType="com.ts.entity.Emp"&gt;
        &lt;id column="emp_id" property="id"/&gt;
        &lt;result column="emp_name" property="name"/&gt;
    &lt;/association&gt; 
&lt;/resultMap&gt;

&lt;select id="getUserWithAssociations" resultMap="userResutlMap"&gt;
    SELECT u.*, d.id as dept_id, d.name as dept_name, 
           e.id as emp_id, e.name as emp_name
    FROM t_user u
    LEFT JOIN t_dept d ON u.dept_id = d.id
    LEFT JOIN t_emp e ON u.emp_id = e.id
    WHERE u.id = #{id}
&lt;/select&gt;</code></pre>
                </div>
                
                <!-- ResultType Example -->
                <div class="highlight">
                    <div class="px-4 py-3 bg-gray-800 text-white rounded-t-lg flex justify-between items-center">
                        <span class="font-mono text-sm">ResultType示例</span>
                        <button class="text-xs bg-gray-700 hover:bg-gray-600 px-2 py-1 rounded" onclick="copyCode('resulttype-code')">
                            <i class="far fa-copy mr-1"></i>复制
                        </button>
                    </div>
                    <pre id="resulttype-code" class="code-block rounded-b-lg"><code>&lt;!-- 简单查询，字段名与属性名一致 --&gt;
&lt;select id="getUserById" resultType="com.ts.entity.User"&gt;
    SELECT id, username, password
    FROM t_user
    WHERE id = #{id}
&lt;/select&gt;

&lt;!-- 使用别名使字段名匹配属性名 --&gt;
&lt;select id="getUserWithAlias" resultType="com.ts.entity.User"&gt;
    SELECT 
        id,
        username,
        password as pw,
        create_time as createTime
    FROM t_user
    WHERE id = #{id}
&lt;/select&gt;</code></pre>
                </div>
            </div>
        </section>

        <!-- Best Practices Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold text-gray-800 mb-6 flex items-center">
                <i class="fas fa-lightbulb text-yellow-500 mr-3"></i>
                最佳实践建议
            </h2>
            
            <div class="bg-blue-50 border-l-4 border-blue-500 p-4 mb-6 rounded-r-lg">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <i class="fas fa-info-circle text-blue-500 text-xl"></i>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-lg font-medium text-blue-800">相同点</h3>
                        <div class="mt-2 text-blue-700">
                            <p>无论使用ResultMap还是ResultType，SQL执行后都会产生结果集，MyBatis会根据配置决定如何将结果封装到指定的Java实体类中。</p>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-6">
                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                    <h3 class="text-xl font-semibold mb-3 text-gray-800 flex items-center">
                        <i class="fas fa-thumbs-up text-green-500 mr-2"></i>
                        推荐使用ResultMap的场景
                    </h3>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>查询结果包含多表关联数据</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>数据库列名与Java属性名不一致</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>需要处理复杂的数据类型转换</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>映射配置需要多处复用</span>
                        </li>
                    </ul>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                    <h3 class="text-xl font-semibold mb-3 text-gray-800 flex items-center">
                        <i class="fas fa-exclamation-triangle text-yellow-500 mr-2"></i>
                        使用ResultType的注意事项
                    </h3>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check text-yellow-500 mt-1 mr-2"></i>
                            <span>确保查询列顺序与Java属性声明顺序一致</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-yellow-500 mt-1 mr-2"></i>
                            <span>列名应与属性名相同，或使用SQL别名</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-yellow-500 mt-1 mr-2"></i>
                            <span>仅适用于简单的单表查询</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-yellow-500 mt-1 mr-2"></i>
                            <span>不适用于嵌套结果或集合映射</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-lg font-medium text-white">技术小馆</h3>
                    <p class="mt-1 text-sm">分享前沿技术，探索编程之美</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="footer-link text-blue-400 hover:text-blue-300 transition duration-150 ease-in-out">
                        <i class="fas fa-external-link-alt mr-1"></i> 访问技术小馆
                    </a>
                </div>
            </div>
            <div class="mt-6 pt-6 border-t border-gray-800 text-center text-sm">
                <p>© 2023 技术小馆. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        function copyCode(elementId) {
            const codeElement = document.getElementById(elementId);
            const range = document.createRange();
            range.selectNode(codeElement);
            window.getSelection().removeAllRanges();
            window.getSelection().addRange(range);
            document.execCommand('copy');
            window.getSelection().removeAllRanges();
            
            // 显示复制成功的提示
            const button = event.target.closest('button');
            const originalText = button.innerHTML;
            button.innerHTML = '<i class="fas fa-check mr-1"></i>已复制';
            button.classList.add('bg-green-600');
            button.classList.remove('bg-gray-700', 'hover:bg-gray-600');
            
            setTimeout(() => {
                button.innerHTML = originalText;
                button.classList.remove('bg-green-600');
                button.classList.add('bg-gray-700', 'hover:bg-gray-600');
            }, 2000);
        }
    </script>
</body>
</html>
```